from PyQt5.QtWidgets import QWidget, QLabel, QVBoxLayout, QPushButton
from PyQt5.QtCore import pyqtSignal


class FailDialog(QWidget):
    failDialogBtnOkSig = pyqtSignal()

    def __init__(self):
        super().__init__()
        self.setWindowTitle("snake")
        self.setFixedSize(200, 100)

        self.vl = QVBoxLayout()
        self.msg = QLabel("游戏结束")
        self.btnOk = QPushButton("确定")

        self.vl.addWidget(self.msg)
        self.vl.addWidget(self.btnOk)

        self.setLayout(self.vl)

        self.btnOk.clicked.connect(self.handleBtnOk)

    def handleBtnOk(self):
        self.failDialogBtnOkSig.emit()
        self.close()
